const Core = require('@alicloud/pop-core')

var client = new Core({
  // Please ensure that the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set.
  accessKeyId: 'DTtbOMKM4ddsPETh',
  accessKeySecret: 'yhMFHArq5VJUe28bVzgfiiVKT2hFFk',
  // securityToken: process.env['ALIBABA_CLOUD_SECURITY_TOKEN'], // use STS Token
  endpoint: 'https://vod.cn-shanghai.aliyuncs.com',
  apiVersion: '2017-03-21'
})

var params = {
  CoverURL: 'aa',
  FileName: 'C:\\b.mp4',
  Title: 'test'
}

var requestOption = {
  method: 'POST',
  formatParams: false
}

const reqTest = (ctx) => {
  ctx.body = '11'
  client.request('CreateUploadVideo', params, requestOption).then(
    (result) => {
      ctx.body = {
        code: 0,
        data: result,
        message: '上传视频成功！'
      }
      console.log(JSON.stringify(result))
      ctx.body = '11'
    },
    (ex) => {
      console.log(ex)
    }
  )
}

module.exports = { reqTest }
